package ltd.followkba.comment.edit;

import static ltd.advskin.MSKIN.MTOAST;

/**
 * Created by Patrick on 2016/11/25.
 * 编辑任务
 */

//public class EditTasksActivity extends SkinActivity {
//	private byte gAppType;
//	private BTaskRun mBTaskRun;
//	private EditText mEditUserInfo;
//	private EditText mEditAccountStatus;
//	private EditText mEditStepTime;
//	private EditText mEditTaskIndex;
//	private EditText mEditCommentQty;
//	private ImageView ivHeadEditTasks;
//	private TextView tvNameEditTasks;
//	private TextView tvUserIdEditTasks;
//	private TextView tvSongListEditTasks;
//	private DbsTypeUserID mFavoriteFile;
//	private CheckBox cbAutoCare;
//	private CheckBox cbAutoFollow;
//	private EditText etCareSong;
//	private EditText etCareComment;
//	private EditText etCareFans;
//	private EditText etFollowSong;
//	private EditText etFollowComment;
//	private EditText etFollowFans;
//
//
//	public static void startWithParamete(BTaskRun bTaskRun){
//		MBAPP.mSaveBTaskRun = bTaskRun;
//		MRAM.mActivity.startActivity(new Intent(MRAM.mActivity, EditTasksActivity.class));
//	}
//
//	@Override
//	protected void onCreate(Bundle savedInstanceState)	{
//		super.onCreate(savedInstanceState);
//		setContentView(R.layout.edit_tasks_layout);
//		mBTaskRun = MBAPP.mSaveBTaskRun;
//		MBAPP.mSaveBTaskRun = null;
////		MSTRING("EditTasksActivity onCreate A "+mBTaskRun.mBAccount.AccountName+" "+mBTaskRun.mOwnDetail);
//		gAppType = mBTaskRun.AppType;
//		mFavoriteFile = new DbsTypeUserID(DbsTypeUserID.USER_FAVORITE, gAppType);
//		initView();
//		showInfo();
//	}
//
//	private void initView(){
//		mKcHeaderView = (KcHeaderView) findViewById(R.id.khvEditTasks);
//		mKcHeaderView.setTitle("编辑任务", new KcTypeListener() {
//			@Override
//			public void onMessage(int type){
//				switch (type){
//					case KcHeaderView.TYPE_CLICK_LEFT:
//							finish();
//						break;
//				}
//			}
//		});
//
//		mEditUserInfo = (EditText) findViewById(R.id.etUserInfo);
//		mEditAccountStatus = (EditText) findViewById(R.id.etAccountStatus);
//		mEditStepTime = (EditText) findViewById(R.id.etStepTime);
//		mEditTaskIndex = (EditText) findViewById(R.id.etTaskIndex);
//		mEditCommentQty = (EditText) findViewById(R.id.etTotalComment);
//
//		ivHeadEditTasks = (ImageView) findViewById(R.id.ivHeadEditTasks);
//		tvNameEditTasks = (TextView) findViewById(R.id.tvNameEditTasks);
//		tvUserIdEditTasks = (TextView) findViewById(R.id.tvUserIdEditTasks);
////		tvSongListEditTasks = (TextView) findViewById(R.id.tvSongListEditTasks);
//
//		// 按键统一函数处理
//		findViewById(R.id.btUserView).setOnClickListener(onClickListener);
//		findViewById(R.id.btAccountLogin).setOnClickListener(onClickListener);
//		findViewById(R.id.btStepTime).setOnClickListener(onClickListener);
//		findViewById(R.id.btTaskIndex).setOnClickListener(onClickListener);
//		findViewById(R.id.btTotalClear).setOnClickListener(onClickListener);
//		findViewById(R.id.btModifySetting).setOnClickListener(onClickListener);
//
//		cbAutoCare = (CheckBox)findViewById(R.id.cbAutoCare);
////		cbAutoCare.setOnClickListener(onClickListener);
//		cbAutoFollow = (CheckBox)findViewById(R.id.cbAutoFollow);
////		cbAutoFollow.setOnClickListener(onClickListener);
//		etCareSong = (EditText)findViewById(R.id.etCareSong);
//		etCareComment = (EditText)findViewById(R.id.etCareComment);
//		etCareFans = (EditText)findViewById(R.id.etCareFans);
//		etFollowSong = (EditText)findViewById(R.id.etFollowSong);
//		etFollowComment = (EditText)findViewById(R.id.etFollowComment);
//		etFollowFans = (EditText)findViewById(R.id.etFollowFans);
//
//		mKcBottomView = (KcBottomView) findViewById(R.id.kguEditTasks);
//        mKcBottomView.initView(new KcTypeListener() {
//            @Override
//            public void onMessage(int type){
//                switch (type){
//                    case 0:
//                        SongListActivity.startWithParamete(gAppType, mBTaskRun.mOwnDetail.userID, mFavoriteFile);
//                        break;
//
//                    case 2:
////String fileName = mBTaskRun.mOwnDetail.HeadFile;
////MSTRING("EditTasksActivity showInfo A "+MAPI.GET_FILE_LENGTH(fileName)+" "+fileName+" "+ivHeadEditTasks);
////if (MAPI.GET_FILE_LENGTH(fileName) < 500) {
////	fileName = null;
////}
////AdvBitmap.setBitmap(C3_FG_NORMAL | CROP_ROUND10, fileName, R.drawable.c3i_user_head, ivHeadEditTasks);
////SysBitmap sysBitmap = new SysBitmap();
////Bitmap bitmap = sysBitmap.getFileBitmap(fileName);
////ivHeadEditTasks.setImageBitmap(bitmap);
//                    	CommHistoryActivity.startWithParamete(mBTaskRun);
//                        break;
//                }
//            }
//        });
//		mKcBottomView.setItem(0,-1, "查看歌曲列表");
//		mKcBottomView.setItem(2,-1, "查看评论记录");
//	}
//	private void showInfo(){
//		mEditUserInfo.setText(mBTaskRun.mBAccount.AccountName);
//		mEditAccountStatus.setText(mBTaskRun.mBAccount.AccountStatus);
//		mEditStepTime.setText(String.valueOf(mBTaskRun.mBAccount.StepTime));
//		mEditTaskIndex.setText(String.valueOf(mBTaskRun.mBAccount.TaskID));
//		mEditCommentQty.setText(String.valueOf(mBTaskRun.SuccessQty));
//
//		cbAutoCare.setChecked(mBTaskRun.mBAccount.IsAutoCare);
//		etCareSong.setText(String.format("%d", mBTaskRun.mBAccount.AutoCareSongQty));
//		etCareComment.setText(String.format("%d", mBTaskRun.mBAccount.AutoCareCommQty));
//		etCareFans.setText(String.format("%d", mBTaskRun.mBAccount.AutoCareFansQty));
//
//		cbAutoFollow.setChecked(mBTaskRun.mBAccount.IsAutoGift);
//		etFollowSong.setText(String.format("%d", mBTaskRun.mBAccount.AutoGiftSongQty));
//		etFollowComment.setText(String.format("%d", mBTaskRun.mBAccount.AutoGiftCommQty));
//		etFollowFans.setText(String.format("%d", mBTaskRun.mBAccount.AutoGiftFansQty));
//
//		String userID = mBTaskRun.mOwnDetail != null ? mBTaskRun.mOwnDetail.userID : "";
//		String fileName = mBTaskRun.mOwnDetail != null ? mBTaskRun.mOwnDetail.headFile : null;
//		String nickName = mBTaskRun.mOwnDetail != null ? mBTaskRun.mOwnDetail.nickName : null;
//MSTRING("EditTasksActivity showInfo A "+MAPI.GET_FILE_LENGTH(fileName)+" "+fileName);
//		if (MAPI.GET_FILE_LENGTH(fileName) < 500) {
//			fileName = null;
//		}
//		AdvBitmap.setBitmap(C3_FG_NORMAL | CROP_ROUND10, fileName, R.drawable.c3i_user_head, ivHeadEditTasks);
//		MSKIN.showNickName(nickName, 0, 0, tvNameEditTasks);
//		tvUserIdEditTasks.setText("(" + userID + ")");
//		BUserInfo info = (BUserInfo) mFavoriteFile.getItem(userID);
//		if (info == null) {
//			mFavoriteFile.setItem(userID, mBTaskRun.mOwnDetail);
//		}
//
//		CheckBox cbPauseTask = (CheckBox)findViewById(R.id.cbPauseTask);
//		cbPauseTask.setChecked(mBTaskRun.mBAccount.IsPause);
//		MSTRING("showNewSong D " + info);
//	}
//
//	/**
//	 * 点击事件
//	 */
//	private View.OnClickListener onClickListener = new View.OnClickListener() {
//		@Override
//		public void onClick(View view)
//		{
//			int g4Local_1;
//			String gsLocal_1;
//			String gsLocal_2;
//			Intent intent;
//			switch (view.getId()) {
//				case R.id.btUserView:
//					ModifyUserActivity.startWithParamete(mBTaskRun);
//					break;
//				case R.id.btAccountLogin:
//					UserLoginActivity.startWithParamete(mBTaskRun);
//					break;
//				case R.id.btStepTime:
//					EditText etStepTime = (EditText) findViewById(R.id.etStepTime);
//					gsLocal_1 = etStepTime.getText().toString();
//					g4Local_1 = MAPI.STRING_DEC32(gsLocal_1);
//					if (mBTaskRun.mBAccount.StepTime != g4Local_1) {
//						if (g4Local_1 > 1) {
//							mBTaskRun.mBAccount.StepTime = g4Local_1;
//							MBAPP.setTaskAccount(gAppType, mBTaskRun.mBAccount);
////							MKCS.TaskWrMemory(REC_STEP_TIME, gsLocal_1, mBTaskRun.AppType, mBTaskRun.mOwnDetail.UserIdS);
//							MTOAST("修改评论间隔时间为：" + gsLocal_1 + "秒");
//						} else {
//							MTOAST("不正确的评论间隔时间");
//						}
//					} else {
//						MTOAST("评论间隔时间没有修改");
//					}
//					break;
//				case R.id.btTaskIndex:
//					gsLocal_1 = mEditTaskIndex.getText().toString();
//					g4Local_1 = MAPI.STRING_DEC32(gsLocal_1);
//					MSTRING("btTaskIndex A " + g4Local_1);
//					if ("-1".equals(gsLocal_1)) {
//						MTOAST("成功删除当前的任务");
//						MBAPP.deleteTaskAccount(gAppType, mBTaskRun.mBAccount.AccountName);
//						MKCS.assignTask();
//						view.postDelayed(new Runnable() {
//							@Override
//							public void run() {
//								finish();
//							}
//						}, 1000);
//					} else {
//						List<BAccount> lists = MBAPP.getTaskAccountList(gAppType);
//						int length = lists.size();
//						BAccount bAccount;
//						for (int counter = 0; counter < length; counter++) {
//							bAccount = lists.get(counter);
//							if (g4Local_1 == bAccount.TaskID) {
//								Toast.makeText(EditTasksActivity.this, "修改的编号已经存在，请更换其他编号", Toast.LENGTH_SHORT).show();
//								return;
//							}
//						}
//						// 修改编号
//						int g4Local_2 = mBTaskRun.mBAccount.TaskID;
//						mBTaskRun.mBAccount.TaskID = g4Local_1;
//						MBAPP.setTaskAccount(gAppType, mBTaskRun.mBAccount);
//						gsLocal_2 = String.format("编号从%d修改为%d，正在重新刷新任务", g4Local_2, g4Local_1);
//						MTOAST(gsLocal_2);
//						MKCS.assignTask();
//					}
//					break;
//				case R.id.btTotalClear:
//					MTOAST("总评清0");
//					CMoreUtils cMoreUtils = new CMoreUtils();
//					cMoreUtils.TaskClearCommentQty(mBTaskRun);
//					mEditCommentQty.setText("0");
//					break;
////				case R.id.cbAutoCare:
////					if (cbAutoCare.isChecked()) {
////						if (mBTaskRun.mBAccount.AutoCareSongQty == 0) {
////							mBTaskRun.mBAccount.AutoCareSongQty = 1;
////						}
////						MSTRING("cbAutoCare A "+mBTaskRun.mBAccount.AutoCareSongQty);
////						etCareSong.setText(String.format("%d", mBTaskRun.mBAccount.AutoCareSongQty));
////						etCareComment.setText(String.format("%d", mBTaskRun.mBAccount.AutoCareCommQty));
////						etCareFans.setText(String.format("%d", mBTaskRun.mBAccount.AutoCareFansQty));
////					} else {
////						etCareSong.setText(String.format("%d", 0));
////						etCareComment.setText(String.format("%d", 0));
////						etCareFans.setText(String.format("%d", 0));
////					}
////					break;
////				case R.id.cbAutoFollow:
////					if (cbAutoFollow.isChecked()) {
////						if (mBTaskRun.mBAccount.AutoGiftSongQty == 0) {
////							mBTaskRun.mBAccount.AutoGiftSongQty = 1;
////						}
////						etFollowSong.setText(String.format("%d", mBTaskRun.mBAccount.AutoGiftSongQty));
////						etFollowComment.setText(String.format("%d", mBTaskRun.mBAccount.AutoGiftCommQty));
////						etFollowFans.setText(String.format("%d", mBTaskRun.mBAccount.AutoGiftFansQty));
////					} else {
////						etFollowSong.setText(String.format("%d", 0));
////						etFollowComment.setText(String.format("%d", 0));
////						etFollowFans.setText(String.format("%d", 0));
////					}
////					break;
//				case R.id.btModifySetting:
//					mBTaskRun.mBAccount.IsAutoCare = cbAutoCare.isChecked();
//					mBTaskRun.mBAccount.IsAutoGift = cbAutoFollow.isChecked();
//					mBTaskRun.mBAccount.AutoCareSongQty = MAPI.STRING_DEC32(etCareSong.getText().toString());
//					mBTaskRun.mBAccount.AutoCareCommQty = MAPI.STRING_DEC32(etCareComment.getText().toString());
//					mBTaskRun.mBAccount.AutoCareFansQty = MAPI.STRING_DEC32(etCareFans.getText().toString());
//					mBTaskRun.mBAccount.AutoGiftSongQty = MAPI.STRING_DEC32(etFollowSong.getText().toString());
//					mBTaskRun.mBAccount.AutoGiftCommQty = MAPI.STRING_DEC32(etFollowComment.getText().toString());
//					mBTaskRun.mBAccount.AutoGiftFansQty = MAPI.STRING_DEC32(etFollowFans.getText().toString());
//					CheckBox cbPauseTask = (CheckBox)findViewById(R.id.cbPauseTask);
//					mBTaskRun.mBAccount.IsPause = cbPauseTask.isChecked();
//					MTOAST("已保存自动关注、自动送花及暂停任务的设置");
//					MBAPP.setTaskAccount(gAppType, mBTaskRun.mBAccount);
//					break;
//			}
//		}
//	};
//
//
//
//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//		List<BTaskRun> lists = MKCS.mBTaskRuns[gAppType];
//		int length = lists.size();
//		BTaskRun bTaskRun;
//		for (int counter = 0; counter < length; counter++) {
//			bTaskRun = lists.get(counter);
//			if (mBTaskRun.AppType == bTaskRun.AppType && mBTaskRun.mBAccount.AccountName.equals(bTaskRun.mBAccount.AccountName)){
//				mBTaskRun = bTaskRun;
//			}
//		}
//		showInfo();
//	}
//
//}
